import { baseRequestClient, requestClient } from '#/api/request';

export namespace Transfer {
  export interface Params {
    attr1: null;
  }
  export interface Row {
    searchValue: null;
    createBy: string;
    createTime: Date;
    updateBy: string;
    updateTime: Date;
    remark: string;
    params: Params;
    transferId: number;
    transferCode: string;
    transferName: string;
    transferType: string;
    deliveryFlag: string;
    recipient: null | string;
    tel: null | string;
    destination: null | string;
    carrier: null | string;
    shippingNumber: null | string;
    confirmFlag: string;
    transferDate: Date;
    status: string;
    attr2: null;
    attr3: number;
    attr4: number;
    attr1: boolean | null | string;
  }
  export interface GetListParams {
    pageNum: number;
    pageSize: number;
  }
  export interface GetListReturn {
    total: number;
    rows: Row[];
    code: number;
    msg: string;
  }
}

// 获取列表
export const getTransferTableList = (params: Transfer.GetListParams) =>
  requestClient.get<Transfer.GetListReturn>('/mes/wm/transfer/list', {
    params,
  });
// 增加转移单
export const addTransfer = (data: Transfer.Row) =>
  requestClient.post<Transfer.GetListReturn>('/mes/wm/transfer', data);

// 删除转移单
export const deleteTransfer = (id: string) =>
  requestClient.delete<Transfer.GetListReturn>(`/mes/wm/transfer/${id}`);

// 修改转移单
export const updateTransfer = (data: Transfer.Row) =>
  requestClient.put<Transfer.GetListReturn>('/mes/wm/transfer', data);

export const getTransferCode = () =>
  baseRequestClient.get<any>('/system/autocode/get/PRODUCTSALSE_CODE');
